import { defineStore } from "pinia";

export const useLoadingStore = defineStore('loading', {
    state: () => ({
        loading: false,
        text: ''
    }),
    actions: {
        start(text?: string) {
            this.loading = true;
            this.text = text || '';
        },
        setText(text: string) {
            this.text = text;
            if (!this.loading) {
                this.loading = true;
            }
        },
        close() {
            this.loading = false;
            this.text = '';
        }
    }
})